//
//  CollectionViewController.m
//  start
//
//  Created by lanou3g on 15-4-21.
//  Copyright (c) 2015年 red. All rights reserved.
//

#import "CollectionViewController.h"

@interface CollectionViewController ()

@end

@implementation CollectionViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark <UICollectionViewDataSource>

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {

    return 1;
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 6;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    
    
    return cell;
}

- (UICollectionReusableView *)collectionView:(UICollectionView*)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    CollectionReusableView *reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];
    if (kind == UICollectionElementKindSectionHeader) {
        
        // 去重用队列取可用的header
        reusableView.selectButton.layer.borderWidth = 1;
        reusableView.selectButton.layer.borderColor = [UIColor blueColor].CGColor;
        reusableView.selectButton.layer.cornerRadius = 5;
        reusableView.selectButton.layer.masksToBounds = YES;
        
        [reusableView.selectButton addTarget:self action:@selector(moreSelectAction:) forControlEvents:UIControlEventTouchUpInside ];
        
        [reusableView.segment1 addTarget:self action:@selector(segmentAction:) forControlEvents:(UIControlEventValueChanged)];
    }
    
    // 返回
    return reusableView;
    
}

- (void)moreSelectAction:(UIButton *)sender{
    NSLog(@"随你选择");
}

-(void)segmentAction:(UISegmentedControl *)sender
{
    if (sender.selectedSegmentIndex == 0) {
        
        NSLog(@"0");
        
    }else if (sender.selectedSegmentIndex == 1){
        
        NSLog(@"1");

    }else{
        NSLog(@"2");

    }
}



#pragma mark <UICollectionViewDelegate>

/*
// Uncomment this method to specify if the specified item should be highlighted during tracking
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
	return YES;
}
*/

/*
// Uncomment this method to specify if the specified item should be selected
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
*/

/*
// Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
	return NO;
}

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	return NO;
}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	
}
*/

@end
